from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from options import options
from login import Login

url = r'http://192.168.226.131/upload/'
username = 'admin'
pwd = 'admin'
driver = webdriver.Chrome(options=options)  # 初始化谷歌浏览器对象
driver.get(url)
driver.maximize_window()

login = Login(driver)
login.login(username, pwd)


#发帖
driver.find_element(By.XPATH,'//*[@id="category_1"]/table/tbody/tr[1]/td[2]/h2/a').click()
driver.find_element(By.ID,'newspecial').click()
driver.find_element(By.ID,'subject').click()
driver.find_element(By.ID,'subject').send_keys('我的帖子01')
#嵌套页面的处理
driver.switch_to.frame('e_iframe')
driver.find_element(By.XPATH,'/html/body').clear()
driver.find_element(By.XPATH,'/html/body').send_keys('我的帖子内容01')
## 注意：跳回默认页面
driver.switch_to.default_content()
driver.find_element(By.ID,'postsubmit').click()
sleep(3)
login.loginout()